package cn.lili.modules.system.entity.dto;

import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.system.entity.dos.LiAuth;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.apache.poi.ss.formula.functions.T;

import java.io.Serial;

/**
 * 授权分页查询参数
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GoodsAuthSearchParams extends PageVO {

    @Serial
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "服务名")
    private String title;

    @ApiModelProperty(value = "编号")
    private String sn;

    @ApiModelProperty(value = "状态")
    private String type;

    /**
     * 构建查询对象
     * @return 查询条件
     * */
    public LambdaQueryWrapper<LiAuth> wrapper(){
        return new LambdaQueryWrapper<LiAuth>()
                .eq(StringUtils.isNotEmpty(type),LiAuth::getType,type)
                .like(StringUtils.isNotEmpty(title),LiAuth::getTitle,title)
                .eq(StringUtils.isNotEmpty(sn),LiAuth::getSn,sn)
                .orderByDesc(LiAuth::getCreateBy);
    }
}
